/* 
 * File:   main.c
 * Author: rafa
 *
 * Created on 27 de Março de 2014, 20:33
 */

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>

#define NRO_ITER 10000000

/*
 * 
 */
int main(int argc, char** argv) {
    int i, contador= 0;
    float px, py;
    float dist;
    
    srand(time(NULL));
    
    for(i= 0; i< NRO_ITER; i++){
        px= (float)rand()/(float)RAND_MAX;
        py= (float)rand()/(float)RAND_MAX;
        
        dist= sqrt(pow(px, 2)+pow(py, 2));
        
        if(dist<= 1)
            contador++;
    }
    printf("pi: %f\n", 4*(float)contador/(float)NRO_ITER);
    return (EXIT_SUCCESS);
}

